// Learn cc.Class:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/class/index.html
// Learn Attribute:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/reference/attributes/index.html
// Learn life-cycle callbacks:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/life-cycle-callbacks/index.html

/**
 * 我的收益界面
 */
cc.Class({
    extends: cc.Component,

    properties: {
        _selectTg: null, //单选按钮选中(我的收益单选按钮)
        earningItemPre: cc.Prefab, //收益item预制
        earningContent: cc.Node,   //scrollview中的content
        
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},
    start () {
        //请求数据
        this.requestRefresh();
    },

    init: function(para){
        this._selectTg =para;
    },

    requestRefresh: function(){
        var recv = function recv(ret) {
            if (ret.Code !== 0) {
                cc.error(ret.Msg);
            }else{
                cc.info('ret收益数据',ret);
                // for(var i=0;i<ret.Data.length;++i){
                //     var waterItem = cc.instantiate(this.backWaterPre); 
                //     waterItem.getComponent('user_backWater_item').init();
                //     this.waterContent.addChild(waterItem);
                // }
            }
          
            //ComponentsUtils.unblock();
        }.bind(this);

        var data = {
            Token:User.getLoginToken(),
            UserCode:User.getUserCode(),
            PageIndex: 1,
            PageSize: 16,
        };
        CL.HTTP.sendRequestRet(DEFINE.HTTP_MESSAGE.POSTEARNRECORD, data, recv.bind(this),"POST");
        //ComponentsUtils.block();
    },

    onClose: function(){
        this._selectTg.isChecked =false;
        this.node.getComponent("Page").backAndRemove();
    },

    // update (dt) {},
});
